/*
 * @Description:
 * @Version: 1.0
 * @Author: liguansheng
 * @Date: 2022-08-25 14:01:03
 * @LastEditors: liguansheng
 * @LastEditTime: 2022-08-26 15:16:50
 */
import axios from '@/utils/request'
import { IPageResult } from './types/base'
import { IClient, ICreateClient, IUpdateClient } from './types/client'

// 新增client详情
export function createClient(data: ICreateClient) {
  return axios<IClient>({
    url: '/api/identity-server/clients',
    method: 'post',
    data,
  })
}

// 删除client
export function deleteClient(id: string) {
  return axios({
    url: `/api/identity-server/clients/${id}`,
    method: 'delete',
  })
}

// 获取client详情
export function updateClient(id: string, data: IUpdateClient) {
  return axios<IClient>({
    url: `/api/identity-server/clients/${id}`,
    method: 'put',
    data,
  })
}

// 分页获取client
export function pagedClients(currentPage = 1, take = 10, filter = '') {
  return axios<IPageResult<IClient>>({
    url: '/api/identity-server/clients',
    method: 'get',
    params: {
      skipCount: take * (currentPage - 1),
      maxResultCount: take,
      filter,
    },
  })
}

// 获取client详情
export function getClient(id: string) {
  return axios<IClient>({
    url: `/api/identity-server/clients/${id}`,
    method: 'get',
  })
}
